package com.example.controller;

import com.example.service.pulsar.PulsarService;
import com.example.vo.req.SendMsgReq;
import lombok.extern.slf4j.Slf4j;
import org.apache.pulsar.client.api.MessageId;
import org.apache.pulsar.client.api.PulsarClientException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.ExecutionException;

/**
 * 查询监控信息的Controller
 *
 * @author yz
 */
@Slf4j
@RestController
@RequestMapping("/pulsar")
public class PulsarController {

    @Autowired
    private PulsarService pulsarService;

    /**
     * 查询磁盘空间数据
     *
     * @return 磁盘空间数据
     */
    @RequestMapping("/sendMsgByParm")
    public MessageId queryDiskSpaceData(@RequestBody SendMsgReq req) throws InterruptedException, ExecutionException, PulsarClientException {
        return pulsarService.send(req.getId(), req.getTopic(), req.getMsg());
    }

}
